﻿// Utility.cs created with MonoDevelop
// User: armando at 20:30 27/01/2009
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;



namespace ABasile
{
	
	
	public class Utility
	{

		

		public string TraceFile = "";
		
		
		
		public Utility()
		{	
			TraceFile = GetPath("~/tracefiles/trace.log");
		}

		
		
		public HtmlLink GetCssLink(string csspath)
		{
			HtmlLink NewLink = new HtmlLink();
			NewLink.Href=csspath;
			NewLink.Attributes["rel"] = "stylesheet";				
			NewLink.Attributes["type"] = "text/css";
			return NewLink;			
		}

		
		
		public string GetPath(string AbsPath)
		{
			return System.Web.Hosting.HostingEnvironment.MapPath(AbsPath);
		}

		
		
		public string[] GetStringByObject(object[] inputarray)
		{
			string[] outputarray = new string[inputarray.Length];
			if (inputarray.Length > 0)
			{
				for (int j=0; j<inputarray.Length; j++)
					outputarray[j] = Convert.ToString(inputarray[j]);
			}
			
			return outputarray;
			
		}

		
		
		public string GetGraph(string Percentage)
		{
			if (Percentage == null)
				Percentage = "0";
			
			if (Percentage.Trim() == "")
				Percentage = "0";
			
			int percentage = int.Parse(Percentage);
			string OutCode = "<table class=\"GraphTable\">\n" + 
				"<tr>\n" + 
				"<td class=\"GraphCompleted\" width=\"" + percentage.ToString() + "\"%>\n" +
				"</td>\n" +
				"<td class=\"GraphNotCompleted\" width=\"" + (100 - percentage).ToString() + "\"%>\n" +
				"</td>\n" +
				"</tr>\n" +
				"</table>\n";
			return OutCode;
		}
		
		
		
		public void AppendTraceFile(string TraceObject, string TraceFunction, string TraceMessage)
		{
			System.IO.StreamWriter SW = new System.IO.StreamWriter(TraceFile, true);
			SW.WriteLine ("DateTime   : " + DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss"));
			SW.WriteLine("Page/Object: " + TraceObject);
			SW.WriteLine("Function   : " + TraceFunction);
			SW.WriteLine(TraceMessage);
			SW.WriteLine("***************************************************************************");
			SW.WriteLine("");
			SW.Flush();
			SW.Close();			
			return;
		}

		
	
		public string GetErrorMessage(string Message)
		{
			string RetMessage = 
				"<table class=\"ErrorTable\"  >\n" +
				"<tr><td align=\"center\" valign=\"middle\" >\n" + Message +
				"</td></tr>\n" +
				"</table>";
			
			return RetMessage;
		}
	
	
		public string GetInfoMessage(string Message)
		{
			string RetMessage = 
				"<table class=\"MessageTable\"  >\n" +
				"<tr><td align=\"center\" valign=\"middle\" >\n" + Message +
				"<br></td></tr>\n" +
				"</table>";
			
			return RetMessage;
		}
		
		
	
		public string GetFieldEditCode(string table, string fieldname, string fieldvalue, 
		                               ref webpman.DBManager DBobject, string MyAccount, 
		                               string ReferenceRecordId)
		{
			string OutField = "";
			System.Collections.ArrayList DataRec = new System.Collections.ArrayList();
			//object[] DataRecName;
			object[] DataRecValue;
			
			// Debug
			// AppendTraceFile("Utility.cs", "GetFieldEditCode", "fieldname=" + fieldname + "\nfieldvalue=" + fieldvalue);
			
			// ID of table (not editable)
			if (fieldname.ToUpper().Trim() == (table.ToUpper().Trim() + "_ID"))
				return fieldvalue;

			
			
			// User authorization on projects
			if (fieldname.ToUpper() == "T_AUTH_TYPE" && table.ToUpper() == "T_AUTH")
			{
				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
				OutField+= "<option "; 
				if (fieldvalue == "P") OutField+= " selected ";
				OutField+= "value=\"P\">Project Manager</option>\n<option ";
				if (fieldvalue == "U") OutField+= " selected ";
				OutField+= "value=\"U\">User</option>\n";
				OutField+= "</select>";
				return OutField;
			}
			

			
			// User type
			if (fieldname.ToUpper() == "T_USER_TYPE" && table.ToUpper() == "T_USER")
			{
				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
				OutField+= "<option "; 
				if (fieldvalue == "A") OutField+= " selected ";
				OutField+= "value=\"A\">Admin</option>\n<option ";
				if (fieldvalue == "U") OutField+= " selected ";
				OutField+= "value=\"U\">User</option>\n";
				OutField+= "</select>";
				return OutField;
			}

			
			
			
			// Category
			if ((fieldname.ToUpper() == "T_CATEGORY_APPLYTO" && table.ToUpper() == "T_CATEGORY") || 
			    (fieldname.ToUpper() == "T_STATE_APPLYTO" && table.ToUpper() == "T_STATE"))
			{
				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
				OutField+= "<option "; 
				if (fieldvalue == "P") OutField+= " selected ";
				OutField+= "value=\"P\">Project</option>\n<option ";
				if (fieldvalue == "T") OutField+= " selected ";
				OutField+= "value=\"T\">Task</option>\n";
				OutField+= "</select>";
				return OutField;
			}
			
			
			
			
			// Projects List
			if (fieldname.ToUpper() == "T_PROJECT_ID" && (table.ToUpper() == "T_AUTH") )
			{
				// Get data from database
				DataRec = DBobject.GetRecordset("SELECT T_PROJECT_ID, T_PROJECT_NAME FROM T_PROJECT ORDER BY T_PROJECT_NAME");
				//DataRecName = ((object[])DataRec[0]);
				
				// init list
				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
				
				// fill data in list
				for (int k=1; k<DataRec.Count; k++)
				{
					DataRecValue = ((object[])DataRec[k]);
					OutField+= "<option ";
					if (fieldvalue == Convert.ToString(DataRecValue[0]) ) 
						OutField+= " selected ";
					OutField+= "value=\"" + DataRecValue[0] + "\">" + Convert.ToString(DataRecValue[1]) + "</option>\n";
				}

				// close list items
				OutField+= "</select>";
				return OutField;
			}

			// Reference project
			if (fieldname.ToUpper() == "T_PROJECT_ID" && (table.ToUpper() == "T_TASK") )
			{
				System.Collections.ArrayList tmpData;

				if (fieldvalue != "")
				{
					tmpData = DBobject.GetRecordset("SELECT T_PROJECT_NAME FROM T_PROJECT WHERE T_PROJECT_ID = " + fieldvalue);
					OutField+= Convert.ToString(((object[])tmpData[1])[0]) + 
						"<input type=\"hidden\" name=\"T_PROJECT_ID\" id=\"T_PROJECT_ID\" value=\"" + fieldvalue + "\" >";
				}
				else
				{
					tmpData = DBobject.GetRecordset("SELECT T_PROJECT_NAME FROM T_PROJECT WHERE T_PROJECT_ID = " + ReferenceRecordId);
					OutField+= Convert.ToString(((object[])tmpData[1])[0]) + 
						"<input type=\"hidden\" name=\"T_PROJECT_ID\" id=\"T_PROJECT_ID\" value=\"" + ReferenceRecordId + "\" >";
				}
				
				tmpData = null;	
				return OutField;
			}
			

			
			
			
			// User List
			if (fieldname.ToUpper() == "T_USER_ID" && 
			    (table.ToUpper() == "T_AUTH" || 
			     table.ToUpper() == "T_TASK" || 
			     table.ToUpper() == "T_PROJECT" ) )
			{
				// Get data from database
				DataRec = DBobject.GetRecordset("SELECT T_USER_ID, T_USER_ACCOUNT FROM T_USER ORDER BY T_USER_ACCOUNT");
				//DataRecName = ((object[])DataRec[0]);
				
				// init list
				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
				
				// fill data in list
				for (int k=1; k<DataRec.Count; k++)
				{
					DataRecValue = ((object[])DataRec[k]);
					OutField+= "<option ";
					if (fieldvalue == Convert.ToString(DataRecValue[0]) ) 
						OutField+= " selected ";
					OutField+= "value=\"" + DataRecValue[0] + "\">" + Convert.ToString(DataRecValue[1]) + "</option>\n";
				}

				// close list items
				OutField+= "</select>";
				return OutField;
			}

				
			if (fieldname.ToUpper() == "T_USER_ID" && table.ToUpper() == "T_ITEM")
			{
				OutField = MyAccount + "<input type=\"hidden\" name=\"T_USER_ID\" id=\"T_USER_ID\" value=\"";
				System.Collections.ArrayList tmpData = 
					DBobject.GetRecordset("SELECT T_USER_ID FROM T_USER WHERE T_USER_ACCOUNT = '" + 
					                      MyAccount.Replace("'","''") + "'");
				
				OutField+= Convert.ToString(((object[])tmpData[1])[0]) + "\" >";
				tmpData = null;
				return OutField;
			}
			
			
			
			// Task List
			if (fieldname.ToUpper() == "T_TASK_ID" && table.ToUpper() == "T_ITEM" ) 
			{

				System.Collections.ArrayList tmpData;

				if (fieldvalue != "")
				{
					tmpData = DBobject.GetRecordset("SELECT T_TASK_NAME FROM T_TASK WHERE T_TASK_ID = " + fieldvalue);
					OutField+= Convert.ToString(((object[])tmpData[1])[0]) + 
						"<input type=\"hidden\" name=\"T_TASK_ID\" id=\"T_TASK_ID\" value=\"" + fieldvalue + "\" >";
				}
				else
				{
					tmpData = DBobject.GetRecordset("SELECT T_TASK_NAME FROM T_TASK WHERE T_TASK_ID = " + ReferenceRecordId);
					OutField+= Convert.ToString(((object[])tmpData[1])[0]) + 
						"<input type=\"hidden\" name=\"T_TASK_ID\" id=\"T_TASK_ID\" value=\"" + ReferenceRecordId + "\" >";
				}
				
				tmpData = null;	
				return OutField;
				
//				// Get data from database
//				DataRec = DBobject.GetRecordset("SELECT T_TASK_ID, T_TASK_NAME FROM T_TASK ORDER BY T_TASK_NAME");
//				//DataRecName = ((object[])DataRec[0]);
//				
//				// init list
//				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
//				
//				// fill data in list
//				for (int k=1; k<DataRec.Count; k++)
//				{
//					DataRecValue = ((object[])DataRec[k]);
//					OutField+= "<option ";
//					if (fieldvalue == Convert.ToString(DataRecValue[0]) ) 
//						OutField+= " selected ";
//					OutField+= "value=\"" + DataRecValue[0] + "\">" + Convert.ToString(DataRecValue[1]) + "</option>\n";
//				}
//
//				// close list items
//				OutField+= "</select>";
//				return OutField;
				
			}
			

			
			// Project state
			if (fieldname.ToUpper() == "T_STATE_ID" && table.ToUpper() == "T_PROJECT" ) 
			{
				// Get data from database
				DataRec = DBobject.GetRecordset("SELECT T_STATE_ID, T_STATE_NAME FROM T_STATE WHERE T_STATE_APPLYTO = 'P' ORDER BY T_STATE_NAME");
				//DataRecName = ((object[])DataRec[0]);
				
				// init list
				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
				
				// fill data in list
				for (int k=1; k<DataRec.Count; k++)
				{
					DataRecValue = ((object[])DataRec[k]);
					OutField+= "<option ";
					if (fieldvalue == Convert.ToString(DataRecValue[0]) ) 
						OutField+= " selected ";
					OutField+= "value=\"" + DataRecValue[0] + "\">" + Convert.ToString(DataRecValue[1]) + "</option>\n";
				}

				// close list items
				OutField+= "</select>";
				return OutField;
			}

			
			
			// Percentage Task
			if ((fieldname.ToUpper() == "T_ITEM_COMPLETE" && table.ToUpper() == "T_ITEM") )
			{
				System.Collections.ArrayList tmpData;
				string OldCompleteValue = "";
				if (ReferenceRecordId != null)
				{
					if (fieldvalue != "")
						OldCompleteValue = fieldvalue;
					else if (ReferenceRecordId != "")
					{
						tmpData = DBobject.GetRecordset("SELECT T_TASK.T_TASK_COMPLETE FROM T_TASK WHERE T_TASK_ID = " + ReferenceRecordId);
						OldCompleteValue = Convert.ToString(((object[])tmpData[1])[0]);
					}
				}
				
				OutField = "<input runat=\"server\" type=\"text\" class=\"EditCellInput\" id=\"T_ITEM_COMPLETE\" " +
					"name=\"T_ITEM_COMPLETE\" value=\"" + OldCompleteValue + "\" size=\"30\" maxlength=\"256\">\n";
			
				return OutField;
				
			}
			
			
			
			// Task state
			if ((fieldname.ToUpper() == "T_STATE_ID" && table.ToUpper() == "T_TASK") ||
			    (fieldname.ToUpper() == "T_STATE_ID" && table.ToUpper() == "T_ITEM") )
			{
				// Get data from database
				DataRec = DBobject.GetRecordset("SELECT T_STATE_ID, T_STATE_NAME FROM T_STATE WHERE T_STATE_APPLYTO = 'T' ORDER BY T_STATE_NAME");
				System.Collections.ArrayList tmpData;
				string OldStateValue = "";
				
				if (ReferenceRecordId != null && table.ToUpper() == "T_ITEM")
				{
					if (ReferenceRecordId != "" && table.ToUpper() == "T_ITEM")
					{
						tmpData = DBobject.GetRecordset("SELECT T_TASK.T_STATE_ID FROM T_TASK WHERE T_TASK_ID = " + ReferenceRecordId);
						OldStateValue = Convert.ToString(((object[])tmpData[1])[0]);
					}
				}
				
				// init list
				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
				
				// fill data in list
				for (int k=1; k<DataRec.Count; k++)
				{
					DataRecValue = ((object[])DataRec[k]);
					OutField+= "<option ";
					if (fieldvalue == Convert.ToString(DataRecValue[0]) ) 
						OutField+= " selected ";
					else if(OldStateValue == Convert.ToString(DataRecValue[0]))
						OutField+= " selected ";
					
					OutField+= "value=\"" + DataRecValue[0] + "\">" + Convert.ToString(DataRecValue[1]) + "</option>\n";
				}

				// close list items
				OutField+= "</select>";
				return OutField;
			}

			

			// Project category
			if (fieldname.ToUpper() == "T_CATEGORY_ID" && table.ToUpper() == "T_PROJECT" ) 
			{
				// Get data from database
				DataRec = DBobject.GetRecordset("SELECT T_CATEGORY_ID, T_CATEGORY_NAME FROM T_CATEGORY WHERE T_CATEGORY_APPLYTO = 'P' ORDER BY T_CATEGORY_NAME");
				//DataRecName = ((object[])DataRec[0]);
				
				// init list
				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
				
				// fill data in list
				for (int k=1; k<DataRec.Count; k++)
				{
					DataRecValue = ((object[])DataRec[k]);
					OutField+= "<option ";
					if (fieldvalue == Convert.ToString(DataRecValue[0]) ) 
						OutField+= " selected ";
					OutField+= "value=\"" + DataRecValue[0] + "\">" + Convert.ToString(DataRecValue[1]) + "</option>\n";
				}

				// close list items
				OutField+= "</select>";
				return OutField;
			}

			
			
			
			// Project category
			if (fieldname.ToUpper() == "T_CATEGORY_ID" && table.ToUpper() == "T_TASK" ) 
			{
				// Get data from database
				DataRec = DBobject.GetRecordset("SELECT T_CATEGORY_ID, T_CATEGORY_NAME FROM T_CATEGORY WHERE T_CATEGORY_APPLYTO = 'T' ORDER BY T_CATEGORY_NAME");
				//DataRecName = ((object[])DataRec[0]);
				
				// init list
				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
				
				// fill data in list
				for (int k=1; k<DataRec.Count; k++)
				{
					DataRecValue = ((object[])DataRec[k]);
					OutField+= "<option ";
					if (fieldvalue == Convert.ToString(DataRecValue[0]) ) 
						OutField+= " selected ";
					OutField+= "value=\"" + DataRecValue[0] + "\">" + Convert.ToString(DataRecValue[1]) + "</option>\n";
				}

				// close list items
				OutField+= "</select>";
				return OutField;
			}

			
			
			// User/Project/Task enable
			if ((fieldname.ToUpper() == "T_USER_ACTIVE" && table.ToUpper() == "T_USER") ||
			    (fieldname.ToUpper() == "T_PROJECT_ACTIVE" && table.ToUpper() == "T_PROJECT") ||
			    (fieldname.ToUpper() == "T_TASK_ACTIVE" && table.ToUpper() == "T_TASK") )
			{
				OutField = "<select runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" name=\"" + fieldname + "\">\n";
				OutField+= "<option "; 
				if (fieldvalue == "1") OutField+= " selected ";
				OutField+= "value=\"1\">Enable</option>\n<option ";
				if (fieldvalue == "0") OutField+= " selected ";
				OutField+= "value=\"0\">Disable</option>\n";
				OutField+= "</select>";
				return OutField;
			}
			
			
			
			
			
			// User password
			if (fieldname.ToUpper() == "T_USER_PASSWORD" && table.ToUpper() == "T_USER")
			{
				OutField = "<input runat=\"server\" type=\"password\" class=\"EditCellInput\" id=\"" + fieldname + "\" " + 
					"name=\"" + fieldname + "\" size=\"20\" maxlength=\"20\" value=\"" + fieldvalue + "\">\n";
				
				return OutField;
			}
			
			
			// Description and Note fields
			if (fieldname.ToUpper() == "T_ITEM_DESCRIPTION" ||
			    fieldname.ToUpper() == "T_PROJECT_NOTES" ||
			    fieldname.ToUpper() == "T_PROJECT_DESCRIPTION" ||
			    fieldname.ToUpper() == "T_TASK_NOTES" ||
			    fieldname.ToUpper() == "T_TASK_DESCRIPTION")
			{
				
				OutField = "<textarea rows=\"4\" cols=\"50\" runat=\"server\" class=\"EditCellInput\" id=\"" + fieldname + "\" " + 
					"name=\"" + fieldname + "\">" + fieldvalue + "</textarea>\n";
				
				return OutField;
			}
			

			
			
			// datetime fields
			if (fieldname.ToUpper() == "T_PROJECT_STARTDATE" ||
			    fieldname.ToUpper() == "T_PROJECT_ENDDATE" ||
			    fieldname.ToUpper() == "T_PROJECT_ESTENDDATE" ||
			    fieldname.ToUpper() == "T_TASK_STARTDATE" ||
			    fieldname.ToUpper() == "T_TASK_ENDDATE" ||
			    fieldname.ToUpper() == "T_TASK_ESTENDDATE")
			{
				
				// Text field standard
				OutField = "<input runat=\"server\" type=\"text\" class=\"EditCellInput\" id=\"" + fieldname + "\" " + 
					"name=\"" + fieldname + "\" value=\"" + fieldvalue + "\" size=\"30\" maxlength=\"20\">\n&nbsp;<span class=\"datacomment\">yyyy-MM-dd hh:mm:ss</span>";
				
				return OutField;
			}

			if (fieldname.ToUpper() == "T_ITEM_INSDATE")
			{
				if (fieldvalue == "")
					fieldvalue = DateTime.Now.Year.ToString() + "-" +
						DateTime.Now.Month.ToString("d2") + "-" +
						DateTime.Now.Day.ToString("d2") + " " +
						DateTime.Now.Hour.ToString("d2") + ":" +
						DateTime.Now.Minute.ToString("d2") + ":" +
						DateTime.Now.Second.ToString("d2");
				
				OutField = "<input runat=\"server\" type=\"text\" class=\"EditCellInput\" id=\"" + fieldname + "\" " + 
					"name=\"" + fieldname + "\" value=\"" + fieldvalue + "\" size=\"30\" maxlength=\"20\">\n&nbsp;<span class=\"datacomment\">yyyy-MM-dd hh:mm:ss</span>";
				return OutField;
			}

			
			
			
			
			// Text field standard
			OutField = "<input runat=\"server\" type=\"text\" class=\"EditCellInput\" id=\"" + fieldname + "\" " + 
					"name=\"" + fieldname + "\" value=\"" + fieldvalue + "\" size=\"30\" maxlength=\"256\">\n";
			
			return OutField;
		}
	
	
		public string GetFieldUpdateCode(string fieldname, string fieldvalue)
		{
			string OutValue = "";
			
			switch (fieldname)
			{
				case "T_USER_ID":
					OutValue= fieldvalue;
					break;
					
				case "T_PROJECT_ID":
					OutValue= fieldvalue;
					break;
				case "T_STATE_ID":
					OutValue= fieldvalue;
					break;
					
				case "T_CATEGORY_ID":
					OutValue= fieldvalue;
					break;
					
				case "T_TASK_ID":
					OutValue= fieldvalue;
					break;
					
				case "T_PROJECT_ACTIVE":
					OutValue= fieldvalue;
					break;
					
				case "T_TASK_ACTIVE":
					OutValue= fieldvalue;
					break;
					
				case "T_TASK_COMPLETE":
					OutValue= fieldvalue;
					break;
					
				case "T_ITEM_COMPLETE":
					OutValue= fieldvalue;
					break;
					
				case "T_TASK_WEIGHT":
					OutValue= fieldvalue;
					break;
					
				case "T_USER_ACTIVE":
					OutValue= fieldvalue;
					break;
					
				default:
					OutValue = "'" + fieldvalue.Replace("'","''") + "'";
					break;
			}
			
			if (OutValue == "" || OutValue == "''")
				OutValue = "NULL";
			
			return OutValue;
		}
	
	
		public string GetMandatoryChars(string tabname, string fieldname)
		{
			
			if ((tabname + "." + fieldname == "T_AUTH.T_AUTH_TYPE") ||
			    (tabname + "." + fieldname == "T_AUTH.T_PROJECT_ID") ||
			    (tabname + "." + fieldname == "T_AUTH.T_USER_ID") ||
			    (tabname + "." + fieldname == "T_CATEGORY.T_CATEGORY_APPLYTO") ||
			    (tabname + "." + fieldname == "T_CATEGORY.T_CATEGORY_NAME") ||
			    (tabname + "." + fieldname == "T_ITEM.T_ITEM_NAME") ||
			    (tabname + "." + fieldname == "T_ITEM.T_ITEM_INSDATE") ||
			    (tabname + "." + fieldname == "T_ITEM.T_ITEM_COMPLETE") ||
			    (tabname + "." + fieldname == "T_ITEM.T_STATE_ID") ||
			    (tabname + "." + fieldname == "T_ITEM.T_USER_ID") ||
			    (tabname + "." + fieldname == "T_ITEM.T_TASK_ID") ||
			    (tabname + "." + fieldname == "T_PROJECT.T_PROJECT_NAME") ||
			    (tabname + "." + fieldname == "T_PROJECT.T_USER_ID") ||
			    (tabname + "." + fieldname == "T_PROJECT.T_STATE_ID") ||
			    (tabname + "." + fieldname == "T_PROJECT.T_CATEGORY_ID") ||
			    (tabname + "." + fieldname == "T_STATE.T_STATE_NAME") ||
			    (tabname + "." + fieldname == "T_STATE.T_STATE_APPLYTO") ||
			    (tabname + "." + fieldname == "T_TASK.T_TASK_WEIGHT") ||
			    (tabname + "." + fieldname == "T_TASK.T_USER_ID") ||
			    (tabname + "." + fieldname == "T_TASK.T_STATE_ID") ||
			    (tabname + "." + fieldname == "T_TASK.T_PROJECT_ID") ||
			    (tabname + "." + fieldname == "T_TASK.T_CATEGORY_ID") ||
			    (tabname + "." + fieldname == "T_TASK.T_TASK_NAME") ||
			    (tabname + "." + fieldname == "T_USER.T_USER_ACCOUNT") ||
			    (tabname + "." + fieldname == "T_USER.T_USER_GROUP") ||
			    (tabname + "." + fieldname == "T_USER.T_USER_PASSWORD") ||
			    (tabname + "." + fieldname == "T_USER.T_USER_REALNAME") )
				return "<span clas=\"datacomment\">*</span>";
			else
				return "";
			
			
		}
		
		public string RandomString(int size, bool lowerCase)
		{
			System.Text.StringBuilder builder = new System.Text.StringBuilder();
			Random random = new Random();
			char ch ;
			
			for(int i=0; i<size; i++)
			{
				ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
				builder.Append(ch);
			}
			
			if(lowerCase)
				return builder.ToString().ToLower();
			
			return builder.ToString();
		}
		
	}
}
